package com.rich.paas.configuration;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * redis配置
 * @author chenhao
 */
@Component
public class RedisTemplateConfiguration {

    @Autowired
    private RedisTemplate redisTemplate;

    public RedisTemplateConfiguration() {

    }

    @PostConstruct
    public void init(){
        RedisSerializer redisSerializer = new StringRedisSerializer();
        redisTemplate.setDefaultSerializer(redisSerializer);
        redisTemplate.setKeySerializer(redisSerializer);
        redisTemplate.setValueSerializer(redisSerializer);
        redisTemplate.setHashKeySerializer(redisSerializer);
        redisTemplate.setHashValueSerializer(redisSerializer);
    }
}
